#pragma once
#include <vector>
#include <memory>
#include "actor.h"
#include "engine/platform/resource_manager.h"
#include "engine/renderer/mesh/particle_system.h"

namespace kanon
{
    class ActorSystem
    {
        friend class RenderSystem2d;
    private:
        std::vector<std::unique_ptr<Actor> > actors;
        uint32_t next_actor_id = 0;

    public:
        // only for debugging.
        Actor& CreateSprite();
        Actor& CreateSprite(const glm::vec2 pos, const glm::vec2 size, const std::shared_ptr<Texture2D>& texture);
        Actor& CreateSprite(const glm::vec2 pos, const glm::vec2 size, const glm::vec4 color);
        Actor& CreateParticleSystem(const glm::vec2& pos, const glm::vec4& color, uint32_t num_particles);
        Actor& CreateCircle(const glm::vec2 pos, const glm::vec2 radius, const glm::vec4 color);

        void Update(float deltaTime);
        int32_t Pick(const glm::vec2& position);
    private:
        bool pointInBox(const glm::vec2& pt, const glm::vec4& box);
    };
}
